package com.yxq.mdt.app.modules.personal.presenter;

import com.yxq.mdt.app.base.BasePresenter;
import com.yxq.mdt.app.modules.personal.bean.EditPicutreResultBean;
import com.yxq.mdt.app.modules.personal.model.UserModel;
import com.yxq.mdt.app.net.ApiModel;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class UserPresenter extends BasePresenter<IUserContract.View, UserModel> implements IUserContract.Presenter {

    public UserPresenter(IUserContract.View rootView, UserModel model) {
        super(rootView, model);
    }


    @Override
    public void saveGaUserExt(String professionId, String shopAddress, String headimg, String residence, String mobile, String position, String interest, String gsName, String concernProfession, String shopName, String qqNum, String wxImg, String education, String cardShareWord, String topicShareWord, String sex, String oftenToPace, String generation, String posterImg, String shopLogo, String email, String tel, String showHot, String mapLng, String mapLat, String age, String constellation, String birthday, String birthdayShow, String marriage, String marriageShow, String sexual, String sexualShow, String friendsIntention, String loveType, String residenceCode, String hometown, String hometownCode, String userProfile) {
        mBaseModel.saveGaUserExt(professionId, shopAddress, headimg, residence,
                mobile, position, interest, gsName,
                concernProfession, shopName, qqNum, wxImg,
                education, cardShareWord, topicShareWord, sex,
                oftenToPace, generation, posterImg, shopLogo,
                email, tel, showHot, mapLng, mapLat,
                age, constellation, birthday, birthdayShow,
                marriage, marriageShow, sexual, sexualShow,
                friendsIntention, loveType, residenceCode, hometown,
                hometownCode, userProfile, new ApiModel.CommonCallback<String>() {
                    @Override
                    public void onSuccess(String data) {
                        mRootView.onSaveSuccess(data);
                    }

                    @Override
                    public void onError(String errMsg) {
                        mRootView.onSaveFailed(errMsg);
                    }
                });
    }

    public void updateAttribute(String data) {

        final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
        RequestBody body = RequestBody.create(JSON, data);

        mBaseModel.updateAttribute(body, new ApiModel.CommonCallback<EditPicutreResultBean>() {
            @Override
            public void onSuccess(EditPicutreResultBean data) {
                mRootView.onUpdateAttributeSuccess(data);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onUpdateAttributeFailed(errMsg);
            }
        });
    }
}
